﻿<Window x:Class="ReplicationExplorer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:Models="clr-namespace:ReplicationExplorer.DomainModel.Distributor.Models" 
        xmlns:Models1="clr-namespace:ReplicationExplorer.DomainModel.Publisher.Models"
        Title="Replication Explorer" 
        xmlns:p="clr-namespace:ReplicationExplorer.Properties" xmlns:Models2="clr-namespace:ReplicationExplorer.DomainModel.Subscriber.Models" Height="{Binding Source={x:Static p:Settings.Default}, Path=Height, Mode=TwoWay}"
        Width="{Binding Source={x:Static p:Settings.Default}, Path=Width, Mode=TwoWay}"
        Left="{Binding Source={x:Static p:Settings.Default}, Path=Left, Mode=TwoWay}"
        Top="{Binding Source={x:Static p:Settings.Default}, Path=Top, Mode=TwoWay}"
        >
    
    <Window.Resources>
        <ContextMenu x:Key="dispositorMenu" >
            <MenuItem Header="Connect to Dispositor"  ToolTip="Connect to Distributor server" Click="connectToDistributorBtn_Click">
                <MenuItem.Icon>
                    <Image Source="Images\ConnectToDistributor.ico" />
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="Diconnect" ToolTip="Disconnect from the Distributor server" Click="disconnectFromDistributorBtn_Click" >
                <MenuItem.Icon>
                    <Image Source="Images\Disconnect.png" Width="16" Height="16" />
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>
        
        <ContextMenu x:Key="distributionDatabaseMenu">
            <MenuItem Name="miSearchTransaction" Header="Search Transaction"  ToolTip="" Click="miSearchTransaction_Click">
                <MenuItem.Icon>
                    <Image Source="Images\Folder.png" Width="16" Height="16"/>
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>
    </Window.Resources>
    
    <DockPanel>
        <StatusBar Width="Auto" Height="25" DockPanel.Dock="Bottom">
            <TextBlock>Status bar</TextBlock>
        </StatusBar>
        <Menu DockPanel.Dock="Top" IsMainMenu="True">
            <MenuItem Header="_File" >
                <MenuItem Header="Connect" Margin="3" Click="connectToDistributorBtn_Click">
                    <MenuItem.Icon>
                        <Image Source="Images\ConnectToDistributor.ico" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Name="miExit" Header="Exit" Margin="3" Command="Close" ></MenuItem>
            </MenuItem>
                
            <!--<MenuItem Header="_Edit" >
                <MenuItem Header="Refresh" Margin="3">
                    <MenuItem.Icon>
                        <Image Source="Images\Refresh.ico" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>-->
            
            <!--<MenuItem Header="_View" >
                <MenuItem Header="View Toolbar" IsCheckable="True" Margin="3"></MenuItem>
                <MenuItem Header="View Statusbar" IsCheckable="True" Margin="3"></MenuItem>
            </MenuItem>-->

            <MenuItem Header="_Help" >
                <MenuItem Name="miAbout" Header="About" Margin="3" Click="miAbout_Click">
                    <MenuItem.Icon>
                        <Image Source="Images\Information.ico" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
        </Menu>
        <ToolBar Width="Auto" Height="Auto" DockPanel.Dock="Top">
            <StackPanel Orientation="Horizontal" >
                <Button Name="connectToDistributorBtn" Click="connectToDistributorBtn_Click" ToolTip="Connect to Distributor server">
                    <Button.Template>
                        <ControlTemplate>
                            <Border HorizontalAlignment="Center" VerticalAlignment="Center" >
                                <Image Source="Images/ConnectToDistributor.png" Width="24" Height="24" Margin="3"/>
                            </Border>
                        </ControlTemplate>
                    </Button.Template>
                </Button>

                <Button Name="disconnectFromDistributorToolbarBtn" ToolTip="Disconnect from the Distributor server" Click="disconnectFromDistributorBtn_Click" >
                    <Button.Template>
                        <ControlTemplate>
                            <Border HorizontalAlignment="Center" VerticalAlignment="Center" >
                                <Image Source="Images/Disconnect.png" Width="24" Height="24" Margin="3" />
                            </Border>
                        </ControlTemplate>
                    </Button.Template>
                </Button>

                <!--<Button Name="refreshBtn">
                    <Button.Template>
                        <ControlTemplate>
                            <Border HorizontalAlignment="Center" VerticalAlignment="Center" >
                                <Image Source="Images/Refresh.png" Width="24" Height="24" Margin="3"/>
                            </Border>
                        </ControlTemplate>
                    </Button.Template>
                </Button>-->
            </StackPanel>
        </ToolBar>
        <Grid Name="gvObjectExplorerPanel" DockPanel.Dock="Left">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200" />
                <ColumnDefinition Width="5"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            
            <Grid.RowDefinitions>
                <RowDefinition />
            </Grid.RowDefinitions>

                        
            <TreeView Name="tvObjectExplorer" Grid.Row="0" Grid.Column="0"
                  ItemsSource="{Binding DistributorServers}"
                  MinWidth="150" 
                  SelectedItemChanged="tvObjectExplorer_SelectedItemChanged"
                  PreviewMouseRightButtonDown="tvObjectExplorer_PreviewMouseRightButtonDown"    >

                <TreeView.Background>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                        <GradientStop Color="White" Offset="0.0" />
                        <GradientStop Color="LightGray" Offset="1.0" />
                    </LinearGradientBrush>
                </TreeView.Background>
                
                               
                <TreeView.ItemContainerStyle>
                    <Style TargetType="{x:Type TreeViewItem}">
                        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                        <Setter Property="FontWeight" Value="Normal" />
                        <Style.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="FontWeight" Value="Bold" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </TreeView.ItemContainerStyle>

                <TreeView.Resources>
                    <HierarchicalDataTemplate DataType="{x:Type Models:DistributorServerViewModel}" 
                                          ItemsSource="{Binding Children}" 
                                              >
                        <StackPanel Orientation="Horizontal"  >
                            <Image Width="16" Height="16" Source="Images\DistributorServer.png" />
                            <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="2" 
                                       ContextMenu="{StaticResource ResourceKey=dispositorMenu}" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type Models:DistributionDatabaseFolderViewModel}" 
                                          ItemsSource="{Binding Children}" >
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16" Source="Images\Folder-Database.png" />
                            <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="2" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type Models:DistributionDatabaseViewModel}" 
                                          ItemsSource="{Binding Children}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16"  Source="Images\DistributionDatabase.png" />
                            <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="2" ContextMenu="{StaticResource ResourceKey=distributionDatabaseMenu}"  />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type Models1:PublisherServerFolderViewModel}" 
                                          ItemsSource="{Binding Children}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16"  Source="Images\Folder-Publishers.png" />
                            <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="2" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type Models1:PublisherServerViewModel}" 
                                          ItemsSource="{Binding Children}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16"  Source="Images\PublisherServer.png" />
                            <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="2" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type Models1:PublicationFolderViewModel}" 
                                          ItemsSource="{Binding Children}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16"  Source="Images\Folder-Publications.png" />
                            <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="2" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type Models1:PublicationViewModel}" 
                                          ItemsSource="{Binding Children}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16"  Source="Images\Publication.png" />
                            <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="2" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type Models2:SubscriptionFolderViewModel}" 
                                          ItemsSource="{Binding Children}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16"  Source="Images\Folder-Subscription.png" />
                            <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="2" />
                        </StackPanel>
                    </HierarchicalDataTemplate>

                    <HierarchicalDataTemplate DataType="{x:Type Models2:SubscriptionViewModel}" 
                                          ItemsSource="{Binding Children}">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="16" Height="16"  Source="Images\Subscription.png" />
                            <TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="2" />
                        </StackPanel>
                    </HierarchicalDataTemplate>


                </TreeView.Resources>
            </TreeView>
            <GridSplitter Name="gvSplitter" Grid.Row="0" Grid.Column="1" Width="5"  HorizontalAlignment="Stretch"  />
            <DockPanel Grid.Row="0" Grid.Column="2" LastChildFill="True" Name="infoPanel" Width="Auto" Height="Auto" >
                <Rectangle  VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="Auto" Height="Auto" >
                    <Rectangle.Fill>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                            <GradientStop Color="White" Offset="0.0" />
                            <GradientStop Color="LightGray" Offset="1.0" />
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                
                <DockPanel.Background>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                        <GradientStop Color="White" Offset="0.0" />
                        <GradientStop Color="Gray" Offset="1.0" />
                    </LinearGradientBrush>
                </DockPanel.Background>
            </DockPanel>
        </Grid>
    </DockPanel>

</Window>
